package com.bang.study.jvm.oom;

/**
 * @Auther: Bang
 * @Date: 2019/9/28 12:58
 * @Description: java虚拟机栈溢出 StackOverflowError
 * @VM: -Xss128k
 */
public class JavaVmStackSOF {

    private int stackLength = 1;

    public void stackLeak(){
        stackLength++;
        stackLeak();
    }

    /**
     * -XX:ThreadStackSize=1m
     * @param args
     * @throws Throwable
     */
    public static void main(String[] args) throws Throwable {
//        Thread.sleep(1000*20);
        JavaVmStackSOF javaVmStackSOF = new JavaVmStackSOF();
        try {
            javaVmStackSOF.stackLeak();
        } catch (Throwable e) {
            System.err.println("stack length: " + javaVmStackSOF.stackLength);
            throw e;
        }
    }
}
